
def l209(target,nums):
    slow = 0
    sum = 0
    res = 0
    for i in range(len(nums)):
        sum += nums[i]

        while sum >= target:
            if res == 0:res = i - slow + 1
            else:res = min(res,i-slow+1)
            sum -= nums[slow]
            slow += 1

        # if sum == target:
        #     print(slow,i,nums[slow:i + 1])
        #     if res == 0:res = i - slow + 1
        #     else:res = min(res,i-slow+1)
        #     sum -= nums[slow]
        #     slow += 1
    return res



if __name__ == '__main__':
    #print(l209(7,[2,3,1,2,4,3]))
    print(l209(11,[1,2,3,4,5]))
    pass